package com.example.wcdb.config.database;

import androidx.annotation.NonNull;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;

import com.tencent.wcdb.database.SQLiteDatabaseCorruptException;

public class CorruptionCallback extends SupportSQLiteOpenHelper.Callback {
    private final SupportSQLiteOpenHelper.Callback delegate;

    public CorruptionCallback(int version, SupportSQLiteOpenHelper.Callback delegate) {
        super(version);
        this.delegate = delegate;
    }

    @Override
    public void onCreate(@NonNull SupportSQLiteDatabase db) {
        delegate.onCreate(db);
    }

    @Override
    public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion, int newVersion) {
        delegate.onUpgrade(db, oldVersion, newVersion);
    }

    @Override
    public void onCorruption(@NonNull SupportSQLiteDatabase db) {
        throw new SQLiteDatabaseCorruptException("检测到数据库错误");
    }
}
